<template>
	<div class="wrap">
		<div class="news-box">
			<div class="news-list" v-for="(item, index) in newList" :key="index" @click="goArticle(item)">
				<p>{{item.title}}</p>
				<span>{{item.pageView}}</span>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				newList: [],
				title: '',
				community: '',
				id: ''
			}
		},
		methods: {
			getParams() {
				var that = this
				that.id = that.$route.query.id
				if(that.$route.query.title) {
					document.title = that.$route.query.title
				}
				that.community = that.$route.query.community
				if (that.community) {
					that.$axios.requestget('/page/article?categoryId=' + that.id + '&community=' + that.community)
						.then((res) => {
							that.newList = res.articles
						})
				} else {
					that.$axios.requestget('/page/article?categoryId=' + that.id)
						.then((res) => {
							that.newList = res.articles
						})
				}
			},
			goArticle: function(item) {
				this.$router.push({
					name: 'articledetail',
					query: {
						id: item.id
					}
				})
			}
		},
		mounted() {
			this.getParams()
		}
	}
</script>

<style>
</style>
